const compressing = require('compressing');
const path = require('path')
const resolve = (dir) => path.join(__dirname, '../../static', dir)

async function uploadFile(req, resp) {
  // req.query.url
  let result = {code: 0}
  let path = resolve('dist.zip')
  console.log("uploadFile-path", path)
  compressing.zip.compressDir('C:/Users/16504/Desktop/互联网/msb-app/dist', resolve('dist.zip')).then(res => {
    console.log("uploadFile-then", res);
    result.message = '压缩完成！'
    resp.json(result);
  }).catch(err => {
    result.message = '压缩失败！'
    resp.json(result);
    console.error("uploadFile-catch", err);
  })
}

module.exports = {
  uploadFile,
};
